<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">

	</head>

	<body>

		<div class="layui-fluid">
			<div class="layui-row" id="view">
				<form class="layui-form" lay-filter="test_detail">
					<div class="layui-card">
						<div class="layui-card-body">

							<div class="layui-form-item">
								<label class="layui-form-label">编号<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<textarea type="text" name="skuids" lay-verify="required" placeholder="请选择编号" autocomplete="off" class="layui-textarea skuid"></textarea>
								</div>
							</div>
							<div class="layui-form-item" style="display: none;">  <!---->
								<label class="layui-form-label">产品编号<span style="color:red">*</span></label>
								<div class="layui-input-block">
									<textarea type="text" name="id" lay-verify="required" placeholder="请选择产品编号" autocomplete="off" class="layui-textarea skuid"></textarea>
								</div>
							</div>
							 
							<div class="layui-form-item">
								<label class="layui-form-label">商品状态</label>
								<div class="layui-input-block on_off"></div>
							</div>
		
							<div class="layui-form-item">
								<label class="layui-form-label">客户端</label>
								<div class="layui-input-block icon_type"></div>
							</div> 
							
						</div>
					</div>
					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js"></script>
		<script src="../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../js/common.js"></script>
		<script>
			 var _data = {
			 	
			 }
			function child(_datas){
				_data = _datas
				console.log(_datas)
				$("textarea[name=id]").val(_datas.id)
				$("textarea[name=skuids]").val(_datas.skuid)
			}
			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form'], function() {
				var $ = layui.$,
					admin = layui.admin,
					form = layui.form;
 
				on_off_show('radio');
				icon_type_show('checkbox')
					
				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					
					_data = Object.assign(_data, data);
					
					_data.type = ''
					for (item in data){ 
						if(/^t/.test(item)){
							if(item.substr(0,4) == 'type'){
								_data.type += data[item]+','
								console.log(item)
								console.log(data[item])
							} 
						} 
					} 
					_data.type = (_data.type.substring(_data.type.length-1) == ',') ? _data.type.substring(0,_data.type.length-1) : _data.type;
					
					layer.confirm('确定要提交数据？', function() {
						loading();
						submitdata(server.updatebanner);
						 
					}, function() {
						layer.msg('取消操作');
					});
					return false;
				});

				function submitdata(_url) {
					$.post(_url, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								layer.alert('操作成功', function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.msg(res.msg);
							}
							closeloading();
						} else {
							closeloading();
							layer.msg('服务器连接错误');
						}
					});
				}

				window.searchdata = function(type) {
					switch(type) {
						case 'skuid':
							layer.open({
								type: 2,
								title: '选择',
								shadeClose: false,
								shade: 0.5,
								maxmin: true, //开启最大化最小化按钮
								area: ['90%', '98%'],
								content: 'choose_skuid.html',
								end: function() {},
								success: function() {}
							});
							break;
						case 'seckill_id':
							layer.open({
								type: 2,
								title: '选择',
								shadeClose: false,
								shade: 0.5,
								maxmin: true, //开启最大化最小化按钮
								area: ['90%', '90%'],
								content: 'choose_limited.html',
								end: function() {},
								success: function() {}
							});
							break;
					}
				}

				function initdata() {
					$.get(server.seckill_goods_detail, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								var data = res.seckill_goods
								form.val("test_detail", data.data);
								form.render();
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}
				
				$("input[name=score]").bind("blur",function(e){
					var market_price = $("input[name=price]").val()
					var score = $("input[name=score]").val()
					console.log(market_price)
					console.log(score)
					if (score> 0 &&  market_price>0) {
						var sumScale = Math.round(parseFloat((score/market_price).toFixed(2)) * 100)  
						$("input[name=score_scale]").val(sumScale)
					}
				})
				$("input[name=score_scale]").bind("blur",function(e){
					var market_price = $("input[name=price]").val()
					var score_scale = $("input[name=score_scale]").val()
					if (score_scale >0 &&  score_scale <=100 && market_price>0 ) {
						var sumScore = Math.round(parseFloat((market_price*score_scale).toFixed(2)) * 100) /10000
						$("input[name=score]").val(sumScore)
					}
				})
			});
		</script>
	</body>

</html>